const { createProxyMiddleware } = require('http-proxy-middleware');

module.exports = function(app) {
  console.log('代理已加载');
  app.use(
    '/api-service-user',
    createProxyMiddleware({
      target: 'http://localhost:9027',
      changeOrigin: true,
      pathRewrite: {
        '^/api-service-user': '/api-service-user', // 保持原始路径
      },
      logLevel: 'debug',
      onProxyReq: (proxyReq, req, res) => {
        console.log('代理请求:', req.url);
      },
      onProxyRes: (proxyRes, req, res) => {
        console.log('代理响应:', proxyRes.statusCode);
      }
    })
  );
};